{extend name="public/base" /}
{block name="theme"}权限管理{/block}
{block name="small_theme"}用户列表{/block}
{block name="css"}
<style>
    .splitline{width:100%;height:0px;border-top:1px dashed #ccc;margin:10px 0;}
    .form-control{height:30px;}
    #phone,#username{border-radius:3px !important;}
    .submit{width:120px;height:30px;line-height: 30px !important;background:#6fb3e0;color:white;border:0px solid #fff;}
</style>
{/block}
{block name="content"}
<div class="col-xs-12">
    <!-- PAGE CONTENT BEGINS -->
    <div class="row">
        <div class="col-xs-12">
            <h3 class="header blue lighter smaller">
                <i class="ace-icon fa fa-list-alt smaller-90"></i>
                新增用户
                <a href="javascript:showlayer('{:url('add')}');"><i class="ace-icon fa fa-plus smaller-90 middle" data-icon-hide="ace-icon fa fa-minus" data-icon-show="ace-icon fa fa-plus"></i></a>
            </h3>

            <form class="form-inline col-lg-12 col-md-12">
                <div class="form-group col-lg-3 col-md-3" style="width: auto">
                    <label class="col-lg-3 col-md-3" style="width: auto">用户名:</label>
                    <input type="text" class="form-control col-lg-9 col-md-9" id="username" name="username" placeholder="用户名" value="{$where.username}">
                </div>
                <div class="form-group col-lg-3 col-md-3" style="width: auto">
                    <label class="col-lg-3 col-md-3" style="width: auto">电话:</label>
                    <input type="text" class="form-control col-lg-9 col-md-9" id="phone" name="phone" placeholder="电话" value="{$where.phone}">
                </div>
                <div class="form-group col-lg-3 col-md-3" style="width: auto">
                    <label class="col-lg-3 col-md-3" style="width: auto">部门:</label>
                    <select class="form-control col-lg-9 col-md-9" name="depar_id" id="depar_id">
                        <option value=''>全部</option>
                        {volist name="depar" id="vo"}
                        <option value="{$vo.id}" {eq name="$where.depar_id" value="$vo['id']"}selected{/eq}>{$vo._name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group col-lg-3 col-md-3" style="width: auto">
                <input type="submit" value="查询" class="submit">
                </div>
            </form>
            <div class="splitline col-lg-12 col-md-12"></div>

            <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th class="center">
                            <label class="position-relative">
                                <input type="checkbox" class="ace" />
                                <span class="lbl"></span>
                            </label>
                        </th>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>角色</th>
                        <th>电话</th>
                        <th>部门</th>
                        <th>职位</th>
                        <th>微信绑定状态</th>
                        <th>使用状态</th>
                        <th>最后登录时间</th>
                        <th>最后登录IP</th>
                        <th>操作</th>
                    </tr>
                </thead>

                <tbody>
                {volist name="userdata" id='vo'}
                    <tr>
                        <td class="center">
                            <label class="position-relative">
                                <input type="checkbox" class="ace" />
                                <span class="lbl"></span>
                            </label>
                        </td>
                        <td>{$vo.id}</td>
                        <td>{$vo.username}</td>
                        <td>{$vo.auth_text}</td>
                        {eq name="$vo.phone" value="0"}
                        <td></td>
                        {else/}
                        <td>{$vo.phone}</td>
                        {/eq}
                        <td>{$vo.depar_text}</td>
                        <td>{$vo.position_text}</td>
                        <td>{$vo.weixinstatus_text}</td>
                        <td>{$vo.status_text}</td>
                        <td>{$vo.last_login_time}</td>
                        <td>{$vo.last_login_ip}</td>
                        <td>
                            <div class="hidden-sm hidden-xs btn-group">
                                <a class="btn btn-xs btn-warning" href="javascript:showlayer('{:url('edit',['id'=>$vo['id']])}');" title="编辑">
                                    <i class="ace-icon fa fa-edit bigger-120"></i>
                                </a>
                                <a class="btn btn-xs btn-danger" href="javascript:opendel2('{:url('del',['id'=>$vo['id']])}');" title="删除">
                                    <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                </a>
                                <a class="btn btn-xs btn-info" href="javascript:setstates('{:url('group',['id'=>$vo['id']])}');" title="部门授权">
                                    <i class="ace-icon fa fa-flag bigger-120"></i>
                                </a>
                                {eq name="$vo.weixinstatus" value="1"}
                                    <a class="btn btn-xs btn-success" href="javascript:jiebang('{:url('jiebang',['id'=>$vo['id']])}');" title="解绑微信">
                                        <i class="ace-icon fa fa-exchange bigger-120"></i>
                                    </a>
                                {/eq}
                            </div>

                            <div class="hidden-md hidden-lg">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                        <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="{:url('add',['id'=>$vo['id']])}" class="tooltip-info" data-rel="tooltip" title="新增">
                                                <span class="blue">
                                                    <i class="ace-icon fa fa-search-plus bigger-120"></i>
                                                </span>
                                            </a>
                                        </li>
                                        <li>
                                            <a href="{:url('edit',['id'=>$vo['id']])}" class="tooltip-success" data-rel="tooltip" title="编辑">
                                                <span class="green">
                                                    <i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
                                                </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a href="javascript:opendel('{:url('del',['id'=>$vo['id']])}');" class="tooltip-error" data-rel="tooltip" title="删除">
                                                <span class="red">
                                                    <i class="ace-icon fa fa-trash-o bigger-120"></i>
                                                </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="page" style="text-align: center">{$page}</div>

        </div><!-- /.span -->
    </div><!-- /.row -->
</div><!-- /.col -->
{/block}
{block name="js"}
<script>

    //设置启用和禁用路由
    var setStatusUrl = "{:url('setStatus')}";

    //用户授权
    function setstates(url){
        layer.open({
            type: 2,
            anim:6,
            title: '设置权限',
            skin: 'layui-layer-lan', //样式类名
            shadeClose: true,
            shade: 0.8,
            area: ['50%', '80%'],
            content: url,
            end:function(){

            }
        });
    }

    //解绑
    function jiebang(url){
        layer.confirm('确定解绑？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post(url,function(data){
                console.log(data);
                layer.msg(data.msg, {
                    icon: data.code,
                    time:2000,
                },function(){
                    history.go(0);
                });
            });
        });
    }

    highlight_subnav("{:url('index')}");

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            $("#submit").trigger("click");
        }
    });


    /*搜索按钮点击事件*/
    function search() {

        var state = $('#state').val();
        $('#state_text').val(state);

        var leibie = $('#leibie').val();
        $('#leibie_text').val(leibie);

        var channel = $('#channel').val();
        $('#channel_text').val(channel);

        var source = $('#source').val();
        $('#source_text').val(source);

        var diqu = $('#diqu').val();
        $('#diqu_text').val(diqu);

        var jdry = $('#jdry').val();
        $('#jdry_text').val(jdry);

        var yykf = $('#yykf').val();
        $('#yykf_text').val(yykf);

        var mendian = $('#mendian').val();
        $('#mendian_text').val(mendian);

        var menshi = $('#menshi').val();
        $('#menshi_text').val(menshi);

        var personnel = $('#personnel').val();
        $('#personnel_text').val(personnel);

        var invitation_group = $('#invitation_group').val();
        $('#invitation_group_text').val(invitation_group);

        var invitation = $('#invitation-personnel').val();
        $('#invitation-personnel_text').val(invitation);

    }


</script>
{/block}